package com.ctbu.tourism.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;


/**
 * @author linli
 * at 18-3-31 下午4:22
 * 前台控制器:要验证权限（方法访问类型设置为public）
 */

@Controller
public class HomeController {

    @Autowired
    HttpServletRequest httpServletRequest;

    /************************前台基本页面处理********************************/

    //论坛首页主体
    @GetMapping({"/","/home","/home/index","/index"})
    String index(){
        return "home/index";
    }

    @GetMapping("/user")
    public String user(){
        return "home/user";
    }

    @GetMapping("/user/set")
    public String setting(){
        return "home/set";
    }

    @GetMapping("/publish")
    String publish(){
        return "home/publish";
    }

    @GetMapping("/grade")
    String grade(){
        return "home/grade";
    }

    @GetMapping("/post/{id}")
    String post(@PathVariable("id") Integer id){
        HttpSession session = httpServletRequest.getSession();
        session.setAttribute("postid",id);
        return "home/post";
    }
    @GetMapping("/forum")
    String forum(){
        return "home/forum";
    }

    @GetMapping("/hot")
    String hot(){
        return "home/hot";
    }

    @GetMapping("/repo")
    public String repo(){
        return "home/repo";
    }

    @GetMapping("/visitor/{id}")
    String userfk(@PathVariable("id") Integer id){
        HttpSession session = httpServletRequest.getSession();
        session.setAttribute("fkuid",id);
        return "home/userfk";
    }

    @GetMapping("/collection")
    public String collection(){
        return "home/collection";
    }


    @GetMapping("/safe")
    String safe(){
        return "home/safe";
    }

    /************************前台基本页面处理********************************/



}
